﻿$(function () {
    $("#btnSubmitPwdByEmail").live("click", getPwdByEmail);//根据邮箱找回密码
    $("#btnSubmitPwdByMobile").live("click", getPwdByMobile);//根据手机找回密码


    function getPwdByEmail() {
        var emialExp = /\w@\w*\.\w/;
        var strNum = $("#email").val();
        if (!emialExp.test(strNum)) {
            alert("请输入正确格式的邮箱");
            return;
        };
        var $this = $(this);
        var oldStr = $this.text();
        $.ajax({
            url: "../User/GetPasswordAction",
            dataType: "json",
            data: { strNum: strNum, type: 1 },
            beforeSend: function () {
                $this.text("操作中...");
            },
            type: "post",
            success: function (res) {
                if (res.Result.IsSuccess) {
                    alert("密码已经发送到注册邮箱，请注意查收");
                }
                else {
                    alert(res.Result.ErrMessage);
                }
            },
            complete: function () {
                $this.text(oldStr);
            }
        });
    };

    function getPwdByMobile() {
        var mobileExp = /^(1[0-9]{10})$/;
        var strNum = $("#mobile").val();
        if (!mobileExp.test(strNum)) {
            alert("请输入正确格式的手机号码");
            return;
        };
        var $this = $(this);
        var oldStr = $this.text();
        $.ajax({
            url: "../User/GetPasswordAction",
            dataType: "json",
            data: { strNum: strNum, type: 0 },
            beforeSend: function () {
                $this.text("操作中...");
            },
            type: "post",
            success: function (res) {
                if (res.Result.IsSuccess) {
                    alert("密码已经发送到注册手机，请注意查收");
                }
                else {
                    alert(res.Result.ErrMessage);
                }
            },
            complete: function () {
                $this.text(oldStr);
            }
        });
    };

    $(".liItemPwd").click(function () {
        var $this = $(this);
        var index = $this.index();
        $this.siblings().removeClass("liSelectedPwd");
        $this.addClass("liSelectedPwd");
        $(".IcenterItemPwd").hide().eq(index).show();
    });


});